package com.nbsaas.boot.site.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.code.annotation.data.Dict;
import com.nbsaas.boot.code.annotation.data.DictItem;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import com.nbsaas.boot.rest.filter.Operator;
import lombok.Data;
import org.hibernate.annotations.Comment;

import javax.persistence.*;

@FormAnnotation(title = "动态页面管理", menu = "1,2,66")
@Data
@Entity
@Table(name = "bs_page")
public class DynamicPage extends AbstractEntity {

    @SearchItem(label = "页面key", key = "key", name = "key")
    @Column(name = "page_key")
    @FormField(title = "页面key", sortNum = "1", grid = true, required = true, col = 22)
    private String key;


    @FormField(title = "分类", sortNum = "2", grid = true, col = 22, type = InputType.select, option = "dynamicPageCatalog")
    @SearchItem(label = "分类", name = "dynamicPageCatalog", key = "dynamicPageCatalog.id", operator = Operator.eq, type = InputType.select, classType = Long.class)
    @FieldName
    @FieldConvert
    @ManyToOne(fetch = FetchType.LAZY)
    private DynamicPageCatalog dynamicPageCatalog;

    @Comment("是否在首页显示")
    @Dict(
            items = {
                    @DictItem(label = "否", value = 2),
                    @DictItem(label = "是", value = 1)
            }
    )
    private Integer showHome;

    @Comment("排序号")
    private Integer sortNum;


    @SearchItem(label = "标题", key = "name", name = "name")
    @FormField(title = "页面标题", sortNum = "2", grid = true, width = "180", required = true, col = 22)
    private String name;

    @FormField(title = "图片", type = InputType.image, col = 22)
    private String logo;


    @FormField(title = "摘要", col = 22, type = InputType.textarea)
    private String introduce;


    @Column(length = 5000)
    @FormField(title = "内容", sortNum = "4", type = InputType.richText, col = 22)
    private String note;


}
